#include <vector>
#include <iostream>

using namespace std;

class Solution {
public:
    int findPeakElement(vector<int>& nums) {
        if (nums.size() == 0 || nums.size() == 1) {
            return 0;
        }
        int left = 0;
        int right = nums.size() - 1;
        while (right > left + 1) {
            int middle = (right + left) / 2;
            if (nums[middle + 1] > nums[middle]) {
                left = middle + 1;
            } else if (nums[middle - 1] > nums[middle]) {
                right = middle - 1;
            } else {
                left = middle;
                break;
            }
        }
        if (nums[left] > nums[right]) {
            return left;
        } else {
            return right;
        }
    }
};

int main() {
    vector<int> input = {3, 2};
    Solution solution;
    int output = solution.findPeakElement(input);
    cout << output << endl;
    return 0;
}
